package org.agony2d.view.puppet.supportClasses 
{
	import org.agony2d.core.agony_internal;
	import org.agony2d.view.core.Component;
	import org.agony2d.view.core.FusionComp;
	import org.agony2d.view.core.ComponentProxy;
	
	use namespace agony_internal;
	
public class PuppetComp extends Component
{
	
	final agony_internal function get interactiveZ () : Boolean
	{
		var f:FusionComp;
		
		if (this.m_interactive)
		{
			f = this.parent as FusionComp
			while (f)
			{
				if (!f.m_interactive)
				{
					return false
				}
				f = f.parent as FusionComp
			}
			return true
		}
		return false;
	}
	
	final agony_internal function bubble( type:String ) : void
	{
		var f:FusionComp
		
		m_notifier.dispatchDirectEvent(type)
		f = this.parent as FusionComp;
		while (f)
		{
			f.m_notifier.dispatchDirectEvent(type)
			f = f.parent as FusionComp;
		}	
	}
	
	agony_internal function makeTransform( smoothing:Boolean, external:Boolean ) : void
	{
	}
	
	agony_internal static function getPuppetComp( proxy:ComponentProxy ) : PuppetComp
	{
		var p:PuppetComp
		
		p = (cachedPuppetCompLength > 0 ? cachedPuppetCompLength-- : 0) ? cachedPuppetCompList.pop() : new PuppetComp()
		p.m_proxy = proxy
		p.m_notifier.setTarget(proxy)
		return p
	}
	
	override agony_internal function recycle() : void
	{
		cachedPuppetCompList[cachedPuppetCompLength++] = this
	}
	
	agony_internal static var cachedPuppetCompList:Array = []
	agony_internal static var cachedPuppetCompLength:int
}
}